﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PagingArrows.cs" company="DissingNellemann">
//   
// All rights reserved </copyright>
// <summary>
//   The paging arrows.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
using Website.Models.ViewModels;
using System.Collections.Generic;
namespace Website.Models.Styling
{
    /// <summary>
    ///     The paging arrows.
    /// </summary>
    public class PagingArrows
    {
        #region Public Properties

        /// <summary>
        ///     Gets or sets the action.
        /// </summary>
        public string Action { get; set; }

        /// <summary>
        ///     Gets or sets the current skip.
        /// </summary>
        public int CurrentSkip { get; set; }

        /// <summary>
        ///     Gets or sets the current take.
        /// </summary>
        public int CurrentTake { get; set; }

        /// <summary>
        ///     Gets or sets the current total row count.
        /// </summary>
        public int CurrentTotalRowCount { get; set; }

        /// <summary>
        ///     Gets or sets the total amount of columns.
        /// </summary>
        public int TotalAmountOfColumns { get; set; }

        /// <summary>
        ///     Gets or sets the total amount of columns.
        /// </summary>
        public bool? SortAscending { get; set; }

        /// <summary>
        ///     Gets or sets object that is currently being ordered by
        /// </summary>
        public string CurrentOrderBy { get; set; }

        #endregion

        public static PagingArrows GetPagingArrowsFromHeader<T>(string action, int extraColumns, ListView<T> view)
        {
            return new PagingArrows { 
                Action = action,
                TotalAmountOfColumns = view.Header.Items.Count + extraColumns,
                CurrentSkip = view.Skip,
                CurrentTake = view.Take,
                CurrentTotalRowCount = view.TotalRows,
                CurrentOrderBy = view.OrderBy,
                SortAscending = view.SortAscending
            };
        }
    }
}